<?php
/**
 * Created by PhpStorm.
 * Adminuser: Administrator
 * Date: 2019/2/14 0014
 * Time: 上午 11:05
 */
namespace app\index\validate;
use think\Validate;
class Users extends Validate
{
    //当前的验证规则
    protected $rule=[
             'name'=>['require','max'=>20,'min'=>4,'unique:users'],
             'email'=>['email'],
             'password'=>['max'=>20,'min'=>6,'alphaNum'],//验证某个字段的值是否为字母和数字，'alphaNum'
             'phone'=>['mobile','unique:users'],
      ];
    protected $message  =   [
            'name.require'         => '名称必须',
            'name.max'             => '名称最多不能超过20个字符',
            'name.min'             => '名称不能少于4个字符',
            'name.unique'          => '用户名重复',
            'email.email'          => '请输入正确的邮箱',
            'password.alphaNum'    => '密码只能数字和字母',
            'password.max'         => '密码长度不能大于20个字符',
            'password.min'         => '密码长度不能小于6个字符',
            'phone.phone'          => '手机号格式错误',
            'phone.unique'         => '手机号已存在'
    ];
}